package com.xuchaotong.concurrent;

public class CounterTest {
    public static void main(String[] args) {
        int threadCount = 1000;
        Counter counter = new Counter();
        Thread t1;
        for (int j = 0; j < threadCount; j++) {
            t1 = new Thread(new Runnable() {
                @Override
                public void run() {
                    counter.increase();
                }
            });
            t1.start();
        }

        int i = 0;
        do{
            i = counter.getInitVal();
            System.out.println(i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }while (i != threadCount);
    }
}
